package com.romotc.qqrobot.webqq.qqInterfaceCall;

import java.util.ArrayList;

import org.json.JSONException;
import org.json.JSONObject;

import com.romotc.qqrobot.bean.QQLogedin;
import com.romotc.qqrobot.webqq.bean.Send_buddy_msg2_RequestBody;
import com.romotc.scache.httpreq;

/**
 * 发送消息
 * @author Administrator
 *
 */

public class Send_buddy_msg2_InterCall extends QQInterfaceCall {
	public static final int req_method = httpreq.REQUEST_POST;
	public static final String reqUrl = "http://d.web2.qq.com/channel/send_buddy_msg2";
	private static final int logLevel = 1001;
	public static final String Key_Send2Uin = "Send2Uin";
	public static final String Key_MsgStr = "MsgStr";
	
	public ArrayList<String> myReqHeaders(int reqBodyLen, QQLogedin loginQQ,JSONObject reqDataObj) {
		
		return buildReqHeaders(reqBodyLen, loginQQ
				,"http://d.web2.qq.com/proxy.html?v=20110331002&callback=2",
				"d.web2.qq.com", "http://d.web2.qq.com", "application/x-www-form-urlencoded",
				"*/*", "gzip,deflate,sdch", "zh-CN,zh;q=0.8",
				"UTF-8,*;q=0.5", null);

	}

	/**
	 * 构建消息体
	 */
	public String buildReqBody(JSONObject reqDataObj, QQLogedin loginQQ) {
		//准备消息体
		long send2Uin;
		try {
			send2Uin = reqDataObj.getLong(Key_Send2Uin);
			String msgStr = reqDataObj.getString(Key_MsgStr);//消息内容
			Send_buddy_msg2_RequestBody msgBody = new Send_buddy_msg2_RequestBody(send2Uin, msgStr, loginQQ);
			return msgBody.toString();
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}//接受人的UIN
		return null;
	}

	
	
	public int getReq_method() {
		return req_method;
	}

	public String getReqUrl(JSONObject reqDataObj, QQLogedin loginQQ) {
		return reqUrl;
	}

	public int getLogLevel() {
		return logLevel;
	}

	@Override
	public JSONObject preCall(QQLogedin loginQQ, JSONObject reqDataObj) {
		// TODO Auto-generated method stub
		return reqDataObj;
	}
	
	
	@Override
	public boolean hasPreCall(QQLogedin loginQQ, JSONObject reqDataObj) {
		// TODO Auto-generated method stub
		return false;
	}

	private static Send_buddy_msg2_InterCall instance;
	public static synchronized Send_buddy_msg2_InterCall getInstance() {
		if(instance == null)
			instance = new Send_buddy_msg2_InterCall();
		return instance;
	}
	
	
}
